/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.nanosn.util.parsers.propertiesfile;

import java.io.FileNotFoundException;
import java.io.IOException;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Proxy;

/**
 *
 * @author selkhateeb
 */
public class PropertiesFactory {

    public static <PropertiesInterface> PropertiesInterface create(
            Class<PropertiesInterface> propertiesInterface,
            String propertiesFileName) throws FileNotFoundException, IOException {

        ClassLoader classLoader = propertiesInterface.getClassLoader();
        Class<?>[] interfaces = new Class[]{propertiesInterface};
        InvocationHandler ih = new PropertiesInvocationHandler(propertiesFileName);


        return (PropertiesInterface) Proxy.newProxyInstance(classLoader, interfaces, ih);
    }
}
